import time

from selenium import webdriver
from selenium.webdriver.common.by import By



driver=webdriver.chrome()
driver.get('http"//www.baidu.com/')
driver.maximize_window()
time.sleep(2)
driver.find_element(By.ID,'kw').send_keys('歌舞')
driver.find_element(By.ID,'su').click()
time.sleep(3)
driver.find_element(By.XPATH,'//*[@id="2]/div/div/h3/a').click()

#需要切换窗口driver  才能获取 定位元素
driver.switch_to.window(driver.window_handles[1])
driver.find_element(By.LINK_TEXT,"我的音乐").click()

#截图
driver.get_screenshot_as_file()